add_library(minnow_testing_debug STATIC common.cc)

add_library(minnow_testing_sanitized EXCLUDE_FROM_ALL STATIC common.cc)
target_compile_options(minnow_testing_sanitized PUBLIC ${SANITIZING_FLAGS})

add_custom_target(functionality_testing)
add_custom_target(speed_testing)

macro(add_test_exec exec_name)
  add_executable("${exec_name}_sanitized" EXCLUDE_FROM_ALL "${exec_name}.cc")
  target_compile_options("${exec_name}_sanitized" PUBLIC ${SANITIZING_FLAGS})
  target_link_options("${exec_name}_sanitized" PUBLIC ${SANITIZING_FLAGS})
  target_link_libraries("${exec_name}_sanitized" minnow_testing_sanitized)
  target_link_libraries("${exec_name}_sanitized" minnow_sanitized)
  target_link_libraries("${exec_name}_sanitized" util_sanitized)
  add_dependencies(functionality_testing "${exec_name}_sanitized")

  add_executable("${exec_name}" EXCLUDE_FROM_ALL "${exec_name}.cc")
  target_link_libraries("${exec_name}" minnow_testing_debug)
  target_link_libraries("${exec_name}" minnow_debug)
  target_link_libraries("${exec_name}" util_debug)
  add_dependencies(functionality_testing "${exec_name}")
endmacro(add_test_exec)

macro(add_speed_test exec_name)
  add_executable("${exec_name}" EXCLUDE_FROM_ALL "${exec_name}.cc")
  target_compile_options("${exec_name}" PUBLIC "-O2")
  target_link_libraries("${exec_name}" minnow_optimized)
  target_link_libraries("${exec_name}" util_optimized)
  add_dependencies(speed_testing "${exec_name}")
endmacro(add_speed_test)

add_test_exec(byte_stream_basics)
add_test_exec(byte_stream_capacity)
add_test_exec(byte_stream_one_write)
add_test_exec(byte_stream_two_writes)
add_test_exec(byte_stream_many_writes)
add_test_exec(byte_stream_stress_test)

add_speed_test(byte_stream_speed_test)
